package com.codeduck.filter.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @createDate: 2021-12-25
 */
@Slf4j
public class FirstFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    /**
     * 做过滤处理
     *
     * @param request ServletRequest
     * @param response ServletResponse
     * @param chain FilterChain
     * @return void
     **/
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        log.info("## [{}] 执行 {} 方法：Before！", this.getClass().getSimpleName(), "doFilter");
        //执行下一个filter
        chain.doFilter(request, response);
        log.info("## [{}] 执行 {} 方法：After！", this.getClass().getSimpleName(), "doFilter");
    }

    @Override
    public void destroy() {

    }
}
